<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button id="debounce">debounce</button>

    <script>
        let el = document.getElementById("debounce");

        el.addEventListener('click', debounce(sayHello))

        function debounce(fn) {
            let timer = null;

            return function () {
                clearTimeout(timer)

                timer = setTimeout(() => {
                    fn.apply(this, arguments);
                }, 1000)
            }
        }

        function sayHello() {
            console.log("Hello")
        }
    </script>
</body>

</html>